<div class="result">
    <div class="alert alert-dismissable alert-warning">
        <h4>
            添加当{{ prod_name }}服务模板文件
        </h4> 只有需要配置文件的服务才会在此出现哦,添加配置文件后，记的推送相关项目哦，否则不能产即生效
    </div>
</div>
<form class="form-horizontal" id="form" action="" method="post" role="form">{% csrf_token %}
    <input type="hidden" name="prod_name" value="{{ prod_name }}" />
    <textarea class="form-control" id="id_sls_description" style="height: 600px;" name="salt_code" >{{ data }}</textarea>
    <div class="clearfix"></div>
     {% if "admin" in request.user.department %}
     <div style="margin-top:8px;">
         <input type="submit" id="salt_save" class="btn btn-success btn-block" value="保存" name="save" />
    </div>
    {% endif %}
</form>

{% if "admin" in request.user.department %}
<script type="text/javascript">
    $("#form").bind("submit", function () {
    $.fancybox.showLoading(); // it was $.fancybox.showActivity(); for v1.3.4
    $.ajax({
        type: "POST",
        cache: false,
        url: "/conf/default/{{ prod_name }}/index?save=templates", // make sure your path is correct
        data: $(this).serializeArray(), // your were using $(form).serialize(),
        error: function(request){           // 设置表单提交出错
            alert("表单提交出错，请稍候再试");
            setTimeout($.fancybox.close, 1000);
          },
        dataType:'text',
        success: function (data) {
{#            alert("is ok");#}
            $('.result').html(data);
            $.fancybox.close();
        }
    });
    return false;
    }); // bind
</script>
{% endif %}
